<template>
    <transition name="show">
      <div class="m-notice" v-show="showNotice">
        <h2>{{ title }}</h2>
        <div class="m-msg">{{ message }}</div>
      </div>
    </transition>
  </template>
  
  <script setup>
  import { onMounted, reactive, toRefs } from "vue";
  
  const props = defineProps(["title", "message"]);
  
  const state = reactive({
    showNotice: false,
  });
  
  onMounted(() => {
    state.showNotice = true;
  });
  
  const { showNotice } = toRefs(state);
  </script>
  
  <style lang="scss" scoped>
  @keyframes show {
    0% {
      transform: translateX(370px);
    }
    100% {
      transform: translateX(0px);
    }
  }
  
  @keyframes hide {
    0% {
      transform: translateX(0px);
    }
    100% {
      transform: translateX(370px);
    }
  }
  
  .show-enter-active {
    animation: show 0.3s ease-out;
  }
  
  .show-leave-active {
    animation: hide 0.3s ease-in;
  }
  
  .show-leave-to {
    opacity: 0;
  }
  
  .m-notice {
    position: fixed;
    right: 20px;
    top: 20px;
    width: 330px;
    box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
    padding: 12px;
    z-index: 1000;

    // animation: show 0.3s ease-out;
  
    h2 {
      font-size: 16px;
      font-weight: 500;
    }
  
    .m-msg {
      font-size: 14px;
      color: #606266;
      margin-top: 8px;
    }
  }
  </style>